/* GUI CONVERTED from rewarp01.p (converter v1.76) Fri Aug 17 03:56:15 2001 */
/* rewarp01.p - REPETITIVE                                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.6.1.4 $                                                         */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 7.3      LAST MODIFIED: 03/03/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 02/14/96   BY: jym *G1N8*                */
/* REVISION: 7.3      LAST MODIFIED: 04/03/96   BY: jym *G1S7*                */
/* REVISION: 8.6      LAST MODIFIED: 10/11/97   BY: bvm *K0S7*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Old ECO marker removed, but no ECO header exists *K0S7*                    */
/* $Revision: 1.6.1.4 $    BY: Hiral Kadakia  DATE: 07/24/01 ECO: *N10F*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* WIP ADJUST ANALYSIS REPORT                                                 */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rewarp01_p_1 "Reason"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp01_p_2 "Effective"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp01_p_3 "Processed Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp01_p_4 "Adjust!Percent"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp01_p_5 "Adjust Qty"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

{revars.i}

define variable dept           like wc_dept.
define variable dept1          like wc_dept  label {t001.i}.
define variable effdate        as   date     label {&rewarp01_p_2}.
define variable effdate1       as   date     label {t001.i}.
define variable emp            like op_emp.
define variable emp1           like op_emp   label {t001.i}.
define variable line           like wo_line.
define variable line1          like wo_line  label {t001.i}.
define variable lot            like wo_lot.
define variable lot1           like wo_lot   label {t001.i}.
define variable mch            like wc_mch.
define variable mch1           like wc_mch   label {t001.i}.
define variable part           like wo_part.
define variable part1          like wo_part  label {t001.i}.
define variable reason         like op_rsn.
define variable reason1        like op_rsn   label {t001.i}.
define variable shift          like op_shift.
define variable shift1         like op_shift label {t001.i}.
define variable site           like wo_site.
define variable site1          like wo_site  label {t001.i}.
define variable wkctr          like wc_wkctr.
define variable wkctr1         like wc_wkctr label {t001.i}.
define variable qty_cumproc    like wr_qty_cumproc
                                             column-label {&rewarp01_p_3}.
define variable qty_cumadj     like wr_qty_cumoadj
                                             column-label {&rewarp01_p_5}.
define variable wrdesc         like wr_desc.
define variable ptdesc         like pt_desc1.
define variable percent_adjust as   decimal decimals 2 format "->,>>9.99%"
                                             column-label {&rewarp01_p_4}.
define variable first_display  as   log.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
lot                 colon 20
   lot1                colon 45
   part                colon 20
   part1               colon 45
   site                colon 20
   site1               colon 45
   line                colon 20
   line1               colon 45
   reason              colon 20
   reason1             colon 45
   wkctr               colon 20
   wkctr1              colon 45
   mch                 colon 20
   mch1                colon 45
   dept                colon 20
   dept1               colon 45
   shift               colon 20
   shift1              colon 45
   emp                 colon 20
   emp1                colon 45
   effdate             colon 20
   effdate1            colon 45
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

find first gl_ctrl no-lock.

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

   if lot1 = hi_char
   then
      lot1 = "".
   if part1 = hi_char
   then
      part1 = "".
   if site1 = hi_char
   then
      site1 = "".
   if line1 = hi_char
   then
      line1 = "".
   if reason1 = hi_char
   then
      reason1 = "".
   if wkctr1 = hi_char
   then
      wkctr1 = "".
   if mch1 = hi_char
   then
      mch1 = "".
   if dept1 = hi_char
   then
      dept1 = "".
   if shift1 = hi_char
   then
      shift1 = "".
   if emp1 = hi_char
   then
      emp1 = "".
   if effdate = low_date
   then
      effdate = ?.
   if effdate1 = hi_date
   then
      effdate1 = ?.

   if c-application-mode <> 'web'
   then
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update
             &fields  = " lot     lot1     part   part1   site
                          site1   line     line1  reason  reason1
                          wkctr   wkctr1   mch    mch1    dept
                          dept1   shift    shift1 emp     emp1
                          effdate effdate1"
             &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data'))
   then do:

      bcdparm = "".
      {mfquoter.i lot}
      {mfquoter.i lot1}
      {mfquoter.i part}
      {mfquoter.i part1}
      {mfquoter.i site}
      {mfquoter.i site1}
      {mfquoter.i line}
      {mfquoter.i line1}
      {mfquoter.i reason}
      {mfquoter.i reason1}
      {mfquoter.i wkctr}
      {mfquoter.i wkctr1}
      {mfquoter.i mch}
      {mfquoter.i mch1}
      {mfquoter.i dept}
      {mfquoter.i dept1}
      {mfquoter.i shift}
      {mfquoter.i shift1}
      {mfquoter.i emp}
      {mfquoter.i emp1}
      {mfquoter.i effdate}
      {mfquoter.i effdate1}

      if lot1 = ""
      then
         lot1 = hi_char.
      if part1 = ""
      then
         part1 = hi_char.
      if site1 = ""
      then
         site1 = hi_char.
      if line1 = ""
      then
         line1 = hi_char.
      if reason1 = ""
      then
         reason1 = hi_char.
      if wkctr1 = ""
      then
         wkctr1 = hi_char.
      if mch1 = ""
      then
         mch1 = hi_char.
      if dept1 = ""
      then
         dept1 = hi_char.
      if shift1 = ""
      then
         shift1 = hi_char.
      if emp1 = ""
      then
         emp1 = hi_char.
      if effdate = ?
      then
         effdate = low_date.
      if effdate1 = ?
      then
         effdate1 = hi_date.

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:
find first gl_ctrl no-lock.

define buffer ophist for op_hist.


   {mfphead.i}

   FORM /*GUI*/ 
   with STREAM-IO /*GUI*/  frame detail width 132 no-box down.

   /* SET EXTERNAL LABELS */
   setFrameLabels(frame detail:handle).

   for each op_hist no-lock
      where op_wo_lot     >= lot
      and   op_wo_lot     <= lot1
      and   op_part       >= part
      and   op_part       <= part1
      and   op_site       >= site
      and   op_site       <= site1
      and   op_line       >= line
      and   op_line       <= line1
      and   op_rsn_adjust >= reason
      and   op_rsn_adjust <= reason1
      and   op_wkctr      >= wkctr
      and   op_wkctr      <= wkctr1
      and   op_mch        >= mch
      and   op_mch        <= mch1
      and   op_dept       >= dept
      and   op_dept       <= dept1
      and   op_shift      >= shift
      and   op_shift      <= shift1
      and   op_emp        >= emp
      and   op_emp        <= emp1
      and   op_date       >= effdate
      and   op_date       <= effdate1
      and   can-do(advrep_optypes,op_type)
      and   op__dec02     <> 0
      use-index op_date
      break by op_site by op_part by op_wo_op by op_line
      by op_rsn_adjust
      with width 132 no-box:
      qty_cumadj = op__dec02.

      accumulate qty_cumadj (sub-total by op_rsn_adjust).

      if first-of(op_line)
      then do:
         qty_cumproc = 0.

         do for ophist:
            for each ophist no-lock
               where op_wo_lot >= lot
               and op_wo_lot   <= lot1
               and op_site      = op_hist.op_site
               and op_part      = op_hist.op_part
               and op_wo_op     = op_hist.op_wo_op
               and op_line      = op_hist.op_line
               and op_wkctr    >= wkctr
               and op_wkctr    <= wkctr1
               and op_mch      >= mch
               and op_mch      <= mch1
               and op_dept     >= dept
               and op_dept     <= dept1
               and op_shift    >= shift
               and op_shift    <= shift1
               and op_emp      >= emp
               and op_emp      <= emp1
               and op_date     >= effdate
               and op_date     <= effdate1
               and can-do(advrep_optypes,op_type) :
               qty_cumproc = qty_cumproc + op_qty_comp.
            end.
         end.

         first_display = yes.
      end.

      if last-of(op_rsn_adjust)
      then do:

         if first_display
         then do:
            display
               op_site
               op_part
               op_wo_op
               op_line
               qty_cumproc
            with frame detail STREAM-IO /*GUI*/ .

            first_display = no.
         end.

         percent_adjust =
         ((accum sub-total by op_rsn_adjust qty_cumadj) * 100) /
           qty_cumproc.

         for first rsn_ref
            fields( rsn_code rsn_desc rsn_type )
            where rsn_type = "adjust"
            and   rsn_code = op_rsn_adjust
            no-lock:
         end. /* FOR FIRST rsn_ref */

         display
            space(4)
            op_rsn_adjust          column-label {&rewarp01_p_1}
            rsn_desc               when (available rsn_ref)
            accum sub-total        by    op_rsn_adjust qty_cumadj @ qty_cumadj
            percent_adjust         when (percent_adjust <> ?)
         with frame detail STREAM-IO /*GUI*/ .
         down 1 with frame detail.
      end.

      if last-of(op_line)
      then
         down 1 with frame detail.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

end.

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" lot lot1 part part1 site site1 line line1 reason reason1 wkctr wkctr1 mch mch1 dept dept1 shift shift1 emp emp1 effdate effdate1 "} /*Drive the Report*/
